using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DAL;
using DTO;
using BUS;
public partial class admin_A_tinhtrang_dh_update : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Loaddata();
        }
    }
    protected void btcapnhat_Click(object sender, EventArgs e)
    {
        int id = int.Parse(Request.QueryString["matinhtrang"].ToString());
        if (txttentinhtrang.Text == "")
        {
            TinhTrang_DonHang_BUS.Delete(id);
            Response.Redirect("~/admin/A_tinhtrang_donhang.aspx");
        }
        try
        {
            //int id = int.Parse(Request.QueryString["matinhtrang"].ToString());
            TinhTrang_DonHang_DTO lh = TinhTrang_DonHang_BUS.GetByID(id);
            lh.MaTinhTrang_DH = int.Parse(lmatinhtrang.Text);
            lh.TenTinhTrang = txttentinhtrang.Text;
            TinhTrang_DonHang_BUS.Update(lh);

        }
        catch (Exception ex)
        {
            Response.Redirect(Request.RawUrl);
        }
        Response.Redirect("~/admin/A_tinhtrang_donhang.aspx");
    }
    protected void huy_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/admin/A_tinhtrang_donhang.aspx");
    }
    private void Loaddata()
    {
        //try
        //{
        //    //string tendangnhap = Session["TaiKhoan"].ToString();
        //    //if (tendangnhap != "")
        //    //{
        //    //    lit_tennguoidung.Text = Session["TaiKhoan"].ToString();

        //    //}
        //    //else
        //    //{
        //    //    Session["taikhoan"] = "";
        //    //}
        //    //int ma = int.Parse(Session["manv"].ToString());
        //    //HyperLink1.NavigateUrl = "~/admin/A_suanhanvien.aspx?id=" + ma;
        //}
        //catch (Exception ex)
        //{
        //    Response.Redirect("~/admin/A_dangnhap.aspx");
        //}

        int id = int.Parse(Request.QueryString["matinhtrang"].ToString());
        lmatinhtrang.Text = id.ToString();
        TinhTrang_DonHang_DTO ttsp = TinhTrang_DonHang_BUS.GetByID(id);
        txttentinhtrang.Text = ttsp.TenTinhTrang;


    }
}
